home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-04 | 3.4 KB | 94 lines | [TEXT/MPS ] |
- # **********************************************************************
- #
- # File: Script 1.vu
- #
- # Purpose: to demonstrate some of the basic principles
- # of Virtual User
- #
- # Prerequisites: This script assumes that DrawShapesVU is the
- # currently active application on the target,
- # that the file VU Tutorial 1.ds is in the
- # same folder as the application.
- #
- # Written by: David Gaxiola
- #
- # Copyright © 1992 by Apple Computer, Inc., all rights reserved.
- #
- # **********************************************************************
-
- # Begin main body. ******************************************************
-
- # Set up the system so that the mouse moves fairly slowly. This allows
- # you to watch the actions as they are performed on the target.
-
- mouseSpeed( 12 );
-
- # Open a DrawShapesVU document to test
-
- println "# Opening 'VU Tutorial 1.ds' document.";
- select [ menuItem title:'Open' menu:[ menu title:'File' ] ];
- type keystrokes:{ 'VU Tutorial 1.ds' }; # Type the filename in the open file
- # dialog box.
- select [ button title:'Open' ];
- while not match [window ordinality:1 title:'VU Tutorial 1.ds']
- begin
- Wait(1);
- end;
-
- # The previous while loop gives slower target machines an opportunity to
- # completely open the document window on the screen before the drag and
- # size commands are executed in the next step. If this loop is left out
- # of the script and the target machine is not able to draw the window
- # quickly enough, VU will not be able to find a match for the window
- # specified in the drag and size command statements.
-
- # Position and size the document window. This example sets the window
- # size to the smallest Macintosh screen size: 9".
- println "# Setting up window.";
- drag [window title:'VU Tutorial 1.ds'] absolute:{ 1, 21 };
- size [window title:'VU Tutorial 1.ds'] width:510 height:320;
-
- # If the VU Tutorial 1.ds window is not open, the drag and size commands
- # will select points either somewhere on the Finder desktop or in
- # windows other than the one specified. VU may indicate a match failure
- # and the script will not behave correctly.
-
- # Select the pointer tool, then select the "eyes" in the drawing.
-
- println "# Selecting objects.";
- move absolute:{ 20, 59 }; # move to the pointer tool position.
- click;
- move relative:{ 147, 50 }; # relative offset from the current cursor
- pressKey keyStrokes:{ shiftKey }; # position in the document window
- click;
- move relative:{ 174,0 };
- click;
- releaseKey keyStrokes:{ shiftKey };
-
- # Copy the eyes to the clipboard and paste them back in the window.
- println "# Performing 'copy' and 'paste' operation.";
- select [ menuItem title:'Copy' menu:[ menu ordinal:3 ]];
- select [ menuItem title:'Paste' menu:[ menu title:'Edit' ]];
-
- # Close the window.
- println "# Discarding changes.";
- close [ window title:'VU Tutorial 1.ds' ];
- while not match [ button title:"No" window:1 ]
- begin
- wait(1);
- end;
-
- # The previous while loop waits until the foremost window is a dialog
- # box containing a No button before proceeding to the next step. If this
- # loop is left out of the script and the target machine is not able to
- # draw the dialog box window before VU executes the select statement, VU
- # will not be able to find a match for the dialog box window specified
- # in the select statement.
-
- # Select the No button in the Save dialog box.
-
- select [ button title:'No' w:[ window s:dialog ]];
-
- println "# Finished!";
- # End main body. ***************************************************
-